package com.yequan.hbb.model;

import com.yequan.hbb.entries.DynamicEntries;
import com.yequan.hbb.servers.Servers;
import com.yequan.hbb.utils.ServerUtil;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by DingLong on 2016/10/13.
 */

public class DynamicModel extends MVPModel {
    private DynamicCallback dynamicCallback;

    public DynamicModel(DynamicCallback dynamicCallback) {
        this.dynamicCallback = dynamicCallback;
    }

    public void getData(int pageIndex, int pageSize, boolean android) {
        Call<DynamicEntries> call = ServerUtil.createHttpRequest(Servers.class).getDynamicInfo(pageIndex, pageSize, android, "android-208984F9-8FBF-0000-8643-941020898468&1476190120849");
        call.enqueue(new Callback<DynamicEntries>() {
            @Override
            public void onResponse(Call<DynamicEntries> call, Response<DynamicEntries> response) {
                dynamicCallback.onResponse(response);
            }

            @Override
            public void onFailure(Call<DynamicEntries> call, Throwable t) {
                dynamicCallback.onFailure(t);
            }
        });

    }

    public interface DynamicCallback {
        void onResponse(Response<DynamicEntries> response);

        void onFailure(Throwable t);
    }
}
